import React from 'react'
import style from './Index.module.less'
import { Space, Tooltip } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'

// 获取表格字段配置
export function getColumns () {
  return [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      align: 'center',
      width: 60
    },
    {
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
      width: 100
    },
    // {
    //   title: '照片',
    //   dataIndex: 'ico_file',
    //   key: 'ico_file',
    //   width: 100,
    //   render: (v) => {
    //     if (v && v instanceof Array && v.length > 0) {
    //       return <img src={v.url} className={style.ico} />
    //     }
    //   }
    // },
    {
      title: '机构名称',
      dataIndex: 'institution_name',
      key: 'institution_name',
      width: 110
    },
    {
      title: '学历',
      dataIndex: 'educational',
      key: 'educational',
      width: 80
    },
    {
      title: '手机号',
      dataIndex: 'mobile',
      key: 'mobile',
      width: 100
    },
    {
      title: '任职资格',
      dataIndex: 'qualification',
      key: 'qualification',
      width: 100
    },
    {
      title: '擅长专业',
      dataIndex: 'special',
      key: 'special',
      width: 200
    },
    {
      title: '单位',
      dataIndex: 'structure',
      key: 'structure',
      width: 100
    },
    {
      title: '职业',
      dataIndex: 'occupation',
      key: 'occupation',
      width: 100
    },
    {
      title: '状态',
      dataIndex: 'status2',
      key: 'status2',
      width: 100,
      render: (v, line) => {
        if (line.status_remark2 && v === '已注销') {
          return (
            <Space>
              <span>{v}</span>
              <Tooltip title={line.status_remark2}><QuestionCircleOutlined style={{ color: 'red' }} /></Tooltip>
            </Space>
          )
        }
        return v
      }
    },
    {
      title: '操作',
      dataIndex: 'index',
      key: 'operate',
      width: 100,
      render: (value, line) => {
        return (
          <Space>
            <span className={style['link-btn']} onClick={() => this.showDetail(line)}>详情</span>
            {line.credit_record && <span className={style['link-btn']} onClick={() => { this.setState({ creditVisible: true, creditId: line.id }) }}>诚信档案</span>}
            {line.status2 !== '已注销' && <a className={style['link-btn']} onClick={() => { this.setState({ delVisible: true, modifyData: line }) }}>注销</a>}
          </Space>
        )
      }
    }
  ]
}
